<?php 
// ডাটাবেস কানেকশন
include 'config/db.php'; 

// উপরের হেডার, ন্যাভবার এবং হেড ট্যাগ ইনক্লুড করা হলো
include 'includes/header.php'; 
?>

<style>
    @keyframes marquee {
        0% { transform: translate(0, 0); }
        100% { transform: translate(-100%, 0); }
    }
    
    /* কাস্টম গ্লোয়িং অ্যানিমেশন */
    @keyframes subtleGlow {
        0% { box-shadow: 0 0 15px -3px currentColor; }
        50% { box-shadow: 0 0 25px 2px currentColor; }
        100% { box-shadow: 0 0 15px -3px currentColor; }
    }
</style>

<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 min-h-screen relative">
    
    <div class="fixed top-0 left-0 w-full h-full overflow-hidden -z-10 pointer-events-none">
        <div class="absolute -top-40 -right-40 w-96 h-96 bg-blue-500/10 rounded-full blur-[100px]"></div>
        <div class="absolute top-1/3 -left-20 w-72 h-72 bg-purple-500/10 rounded-full blur-[100px]"></div>
    </div>

    <div class="bg-white/80 backdrop-blur-xl border border-blue-200/60 rounded-[20px] shadow-[0_8px_30px_-5px_rgba(59,130,246,0.15)] flex overflow-hidden items-center h-[50px] mb-12 relative z-10">
        <div class="bg-gradient-to-r from-blue-600 to-indigo-600 text-white h-full flex items-center px-6 font-black text-xs uppercase tracking-widest z-10 shadow-lg">
            <i class="fa-solid fa-bolt mr-2 animate-pulse text-amber-300"></i> Flash News
        </div>
        <div class="whitespace-nowrap animate-[marquee_25s_linear_infinite] pl-[100%] text-slate-700 font-bold text-sm flex items-center">
            Welcome to Virtual Shop! All types of Premium Quality Mail are available now.Hotmail Outlook Gmail Edu Mail Etc. <span class="text-blue-600 mx-2">●</span> Instant delivery guaranteed! <span class="text-blue-600 mx-2">●</span> 24/7 Premium Support. Virtual Shop is your Trusted Shop
        </div>
    </div>

    <div class="mb-12 text-center md:text-left relative z-10">
        <h2 class="text-3xl md:text-[2.5rem] font-black text-slate-900 tracking-tight leading-tight">
            Explore Premium <br class="hidden md:block"><span class="text-transparent bg-clip-text bg-gradient-to-r from-blue-600 to-purple-600">Categories</span>
        </h2>
        <p class="text-slate-500 mt-3 text-sm font-bold">Select a category below to browse our top-tier services.</p>
    </div>

    <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8 relative z-10">
        
        <?php 
        // ক্যাটাগরিগুলো পুরনো থেকে নতুন (ASC) অর্ডারে শো করানোর জন্য কোড আপডেট করা হয়েছে
        $cats_query = mysqli_query($conn, "SELECT * FROM categories WHERE status = 1 ORDER BY id ASC");
        
        if($cats_query && mysqli_num_rows($cats_query) > 0):
            while($cat = mysqli_fetch_assoc($cats_query)): 
                $page_link = "category.php?id=" . $cat['id'];
        ?>
        
        <a href="<?= $page_link ?>" class="group relative block rounded-[2.5rem] p-[2px] transition-all duration-500 hover:-translate-y-3 hover:shadow-[0_20px_40px_-10px_rgba(59,130,246,0.3)] outline-none">
            
            <div class="absolute inset-0 rounded-[2.5rem] bg-gradient-to-br from-slate-200 via-slate-100 to-slate-200 group-hover:from-blue-500 group-hover:via-indigo-500 group-hover:to-purple-500 transition-colors duration-500 opacity-80 group-hover:opacity-100"></div>
            
            <div class="relative h-full bg-white/95 backdrop-blur-sm rounded-[2.4rem] p-8 flex flex-col justify-center items-center text-center overflow-hidden z-10">
                
                <div class="<?= htmlspecialchars($cat['color']) ?> relative w-20 h-20 rounded-[1.5rem] bg-white flex items-center justify-center mb-6 transition-all duration-500 border-2 border-current shadow-[0_5px_15px_-3px_currentColor] group-hover:scale-110 group-hover:bg-slate-50" style="animation: subtleGlow 3s infinite ease-in-out;">
                    <i class="<?= htmlspecialchars($cat['icon']) ?> text-3xl transition-transform duration-500 group-hover:scale-110"></i>
                </div>
                
                <h3 class="font-black text-slate-800 text-xl leading-snug mb-3 transition-colors duration-300 group-hover:text-blue-600">
                    <?= htmlspecialchars($cat['title']) ?>
                </h3>
                
                <p class="text-xs text-slate-500 font-bold line-clamp-2 mb-8 leading-relaxed px-2">
                    <?= htmlspecialchars($cat['description']) ?>
                </p>

                <div class="mt-auto w-full">
                    <span class="flex items-center justify-center w-full px-6 py-3.5 rounded-[1rem] bg-slate-50 text-slate-600 font-black text-[11px] uppercase tracking-widest transition-all duration-500 group-hover:bg-gradient-to-r group-hover:from-blue-600 group-hover:to-indigo-600 group-hover:text-white border border-slate-200 group-hover:border-transparent">
                        View Products <i class="fa-solid fa-arrow-right ml-2 text-sm transform group-hover:translate-x-1 transition-transform"></i>
                    </span>
                </div>
            </div>
        </a>

        <?php 
            endwhile; 
        else: 
        ?>
            <div class="col-span-full py-24 text-center bg-white/50 backdrop-blur-sm rounded-[3rem] border border-slate-200 border-dashed">
                <div class="inline-flex bg-slate-100 p-5 rounded-full text-slate-400 mb-5 shadow-inner">
                    <i class="fa-solid fa-folder-open text-4xl"></i>
                </div>
                <h3 class="text-xl font-black text-slate-700">No Categories Found</h3>
                <p class="text-sm text-slate-500 mt-2 font-bold">Categories added from the admin panel will appear here.</p>
            </div>
        <?php endif; ?>

    </div>

    <div class="mt-24 py-12 bg-white/80 backdrop-blur-xl rounded-[2.5rem] border border-slate-200/60 shadow-[0_8px_30px_-5px_rgba(0,0,0,0.05)] px-8 relative z-10">
        <div class="grid grid-cols-1 md:grid-cols-3 gap-10 divide-y md:divide-y-0 md:divide-x divide-slate-100/80">
            <div class="text-center md:px-6 pt-6 md:pt-0 group cursor-default">
                <div class="bg-blue-50 w-16 h-16 rounded-[1.2rem] flex items-center justify-center mx-auto text-blue-600 mb-5 border border-blue-100 transition-transform duration-300 group-hover:scale-110 group-hover:bg-blue-600 group-hover:text-white shadow-sm">
                    <i class="fa-solid fa-fingerprint text-2xl"></i>
                </div>
                <h4 class="font-black text-slate-900 text-lg">100% Verified</h4>
                <p class="text-xs text-slate-500 mt-2 font-bold leading-relaxed px-4">Every account is checked manually before putting in stock.</p>
            </div>
            <div class="text-center md:px-6 pt-6 md:pt-0 group cursor-default">
                <div class="bg-emerald-50 w-16 h-16 rounded-[1.2rem] flex items-center justify-center mx-auto text-emerald-600 mb-5 border border-emerald-100 transition-transform duration-300 group-hover:scale-110 group-hover:bg-emerald-600 group-hover:text-white shadow-sm">
                    <i class="fa-solid fa-bolt text-2xl"></i>
                </div>
                <h4 class="font-black text-slate-900 text-lg">Instant Delivery</h4>
                <p class="text-xs text-slate-500 mt-2 font-bold leading-relaxed px-4">Get your account credentials instantly after purchase.</p>
            </div>
            <div class="text-center md:px-6 pt-6 md:pt-0 group cursor-default">
                <div class="bg-amber-50 w-16 h-16 rounded-[1.2rem] flex items-center justify-center mx-auto text-amber-600 mb-5 border border-amber-100 transition-transform duration-300 group-hover:scale-110 group-hover:bg-amber-500 group-hover:text-white shadow-sm">
                    <i class="fa-solid fa-headset text-2xl"></i>
                </div>
                <h4 class="font-black text-slate-900 text-lg">24/7 Support</h4>
                <p class="text-xs text-slate-500 mt-2 font-bold leading-relaxed px-4">Our expert team is always ready to assist you anytime.</p>
            </div>
        </div>
    </div>

</main>

<?php 
// মোবাইলের বটম ন্যাভবার ইনক্লুড করা হলো
include 'includes/bottom_nav.php'; 

// ওয়েবসাইটের ফুটার ইনক্লুড করা হলো
include 'includes/footer.php'; 
?>
